from rest_framework.viewsets import GenericViewSet
from utils.my_drf.viewsets import CustomListModelMixin
from utils.my_drf.admin_auth import AdminJwtAuth, AdminPermission
from . import models, serializer
from utils.my_drf.pagination import CommonPageNumberPagination
from django_filters.rest_framework import DjangoFilterBackend
from utils.my_drf.time_filter import TimeFilter


class AdminRecordView(GenericViewSet, CustomListModelMixin):
    authentication_classes = [AdminJwtAuth, ]
    permission_classes = [AdminPermission, ]
    filter_backends = [DjangoFilterBackend, TimeFilter]
    filterset_fields = ['group', 'admin']
    queryset = models.AdminRecord.objects.filter().order_by('-id')
    serializer_class = serializer.AdminRecordSerializer
    pagination_class = CommonPageNumberPagination
